/*
 * Copyright (c) 2023, LXMS (lxinet.cn).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.lxinet.lxms.framework.mybatis.enums;

/**
 * @author zchuanzhao
 * 2018/11/1
 */
public enum  IdType {
    AUTO(0, "数据库ID自增"),
    INPUT(1, "用户输入ID"),
    UUID(2, "UUID"),
    NONE(3, "不设置");

    private final int key;
    private final String desc;

    private IdType(int key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public static IdType getIdType(int idType) {
        IdType[] its = values();
        for(int i = 0; i < its.length; ++i) {
            IdType it = its[i];
            if (it.getKey() == idType) {
                return it;
            }
        }
        return AUTO;
    }

    public int getKey() {
        return this.key;
    }

    public String getDesc() {
        return this.desc;
    }
}
